<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script>
        // var obj = {
        //     age: 18
        // }
        // if (obj['age']) {
        //     console.log('里面有该属性');
        // }
        // else { console.log('里面没有该属性'); }
        var str = 'sdfskflvmshefisvn';
        var o = {};
        for (var i = 0; i < str.length; i++) {
            var chars = str.charAt(i);//打印每个字符串
            if (o[chars]) {
                o[chars]++;

            } else {
                o[chars] = 1;
            }
        }
        //遍历对象
        var max = 0;
        var ch = '';
        for (var k in o) {
            //k 是属性
            //o[k]是属性值
            if (o[k] > max) {
                max = o[k];
                ch = k;
            }
        }
        console.log(max);
        console.log(ch);
    </script>
</head>

<body>

</body>

</html>